import { request } from "@/utils/request";
import { SupplierTable } from "./types";
import Qs from "qs";

/**
 * 查询供应商列表
 * @param data
 * @returns
 */
export const hmSupplierMyList = (data?: SupplierTable) => {
  return request({
    url: "/basic/hmSupplier/my/list",
    method: "get",
    params: data,
  });
};
/**
 * 查询供应商列表-优化速度
 * @param data
 * @returns
 */
export const getHmSupplierMyList = (data?: SupplierTable) => {
  return request({
    url: "/basic/hmSupplier/app/my/list",
    method: "get",
    params: data,
  });
};

/**
 * 研发-查询供应商列表-优化速度
 * @param data
 * @returns
 */
export const getSupplierListInventPe = (data?: SupplierTable) => {
  return request({
    url: "/basic/hmSupplier/getSupplierListInventPe",
    method: "get",
    params: data,
  });
};
/**
 * 查询供应商列表(根据登录账号品类筛选)
 * @param data
 * @returns
 */
export const loginSupplierList = (data?: any) => {
  return request({
    url: '/basic/hmSupplier/loginSupplierList',
    method: 'post',
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    data: Qs.stringify(data)
  });
};
/**
 * 查询我的供应商列表已选品
 * @param data
 * @returns
 */
export const productSelectionList = (data?: any) => {
  return request({
    url: "/basic/hmSupplier/my/productSelectionList",
    method: "get",
    params: data,
  });
};

/**
 * 研发-查询我的供应商列表已选品
 * @param data
 * @returns
 */
export const getNoOptListInvent = (data?: any) => {
  return request({
    url: "/basic/hmSupplier/getNoOptListInvent",
    method: "get",
    params: data,
  });
};
/**
 * 查询我的供应商列表未选品
 * @param data
 * @returns
 */
export const noProductSelectionList = (data?: any) => {
  return request({
    url: "/basic/hmSupplier/my/noProductSelectionList",
    method: "get",
    params: data,
  });
};
/**
 * 供应商详情
 * @param data
 * @returns
 */
export const hmSupplierGet = (id?: string | number) => {
  return request({
    url: "/basic/hmSupplier/" + id,
    method: "get",
  });
};

/**
 * 新增供应商账号
 * @param data
 * @returns
 */
export const addHmSupplier = (data?: SupplierTable) => {
  return request({
    url: "/basic/hmSupplier/add",
    method: "post",
    data: data,
  });
};

/**
 * 查询供应商增类列表
 * @param data
 * @returns
 */
export const hmSupplierList = (data?: SupplierTable) => {
  return request({
    url: "/basic/hmSupplier/list",
    method: "get",
    params: data,
  });
};

/**
 * 新增供应商品类
 * @param data
 * @returns
 */
export const addType = (data?: { supplierId: string | string[] }) => {
  return request({
    url: "/basic/hmSupplier/addType",
    method: "post",
    data: data,
  });
};

// 获取用户详细信息
export const getInfo = () => {
  return request({
    url: "/system/user/getInfoBy",
    method: "get",
  });
};

// 根据部门编号获取详细信息
export const getDept = (deptId: string) => {
  return request({
    url: "/system/dept/getInfoById/" + deptId,
    method: "get",
  });
};

/**
 * 修改账号信息
 * @param data
 */
export const updateHmSupplier = (data?: SupplierTable) => {
  return request({
    url: "/basic/hmSupplier",
    method: "put",
    data: data,
  });
};

// 获取合同信息详细信息
export const getcontract = (id: any) => {
  return request({
    url: "/basic/contract/" + id,
    method: "get",
  });
};

// 查询合同信息列表
export const getcontractList = (data) => {
  return request({
    url: "/basic/contract/list",
    method: "get",
    params: data,
  });
};

/**
 * 新增品牌
 * @param data
 * @returns
 */
export const addBrand = (data?: { supplierId: string | string[] }) => {
  return request({
    url: "/basic/brand",
    method: "post",
    data: data,
  });
};
// 查询品牌列表
export const getbrandList = (data) => {
  return request({
    url: "/basic/brand/list",
    method: "get",
    params: data,
  });
};

// 获取品牌详细信息
export const getbrandId = (id) => {
  return request({
    url: "/basic/brand/" + id,
    method: "get",
  });
};
/**
 * 修改品牌
 * @param data
 */
export const updatebrand = (data?: SupplierTable) => {
  return request({
    url: "/basic/brand",
    method: "put",
    data: data,
  });
};

/**
 * 新增合同信息
 * @param data
 * @returns
 */
export const addContract = (data?: any) => {
  return request({
    url: "/basic/contract",
    method: "post",
    data: data,
  });
};

/**
 * 类目根据id查询pid
 * @param data
 * @returns
 */
export const getListById = (data?: any) => {
  return request({
    url: "/basic/productsCategory/getListById",
    method: "post",
    data: data,
  });
};

// 主播端查询供应商信息
export const supplierList = (data?: any) => {
  return request({
    url: "/basic/loan/supplierList",
    method: "get",
    params: data,
  });
};
